/*
 * MangaBotApp.java
 */

package mangabot;

import java.util.List;
import mangabot.daos.MangaDAO;
import mangabot.pojos.Manga;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class MangaBotApp extends SingleFrameApplication {

    private static final Logger logger = Logger.getLogger(MangaBotApp.class);

    /**
     * At startup create and show the main frame of the application.
     */
    @Override protected void startup() {
        show(new MangaBotView(this));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of MangaBotApp
     */
    public static MangaBotApp getApplication() {
        return Application.getInstance(MangaBotApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {

        List<Manga> listing = new MangaDAO().retrieveListing();
        Manga manga = new MangaDAO().retrieveManga(listing.get(0).getDirectory());

        logger.info("Manga details: title [" + manga.getTitle() + "], directory[" + manga.getDirectory() + "], logo [" + manga.getLogo() + "], artist [" + manga.getArtist() + "], author [" + manga.getAuthor() + "], rank [" + manga.getRank() + "], categories[" + StringUtils.join(manga.getCategories(), ", ") + "], summary [" + manga.getSummary() + "]");

        launch(MangaBotApp.class, args);
    }
}
